package com.zycfc.zsf.boot.util.ead;

import java.security.*;
import org.slf4j.*;

public class EadTest
{
    private static final Logger log;
    
    public static void main(final String[] args) throws Exception {
        final String salt = "12345";
        final String txt = "01234567012345670123456701234567";
        String pwd = EadMD5Utils.encrypt(txt, salt);
        EadTest.log.info(pwd);
        pwd = EadMD5Utils.encrypt(txt);
        EadTest.log.info(pwd);
        final byte[] key = AESUtils.initSecretKey();
        EadTest.log.info("key\uff1a" + AESUtils.showByteArray(key));
        final Key k = AESUtils.toKey(key);
        final String data = "AES\u6570\u636e";
        EadTest.log.info("\u52a0\u5bc6\u524d\u6570\u636e: string:" + data);
        final byte[] encryptData = AESUtils.encrypt(data, k);
        EadTest.log.info("\u52a0\u5bc6\u540e\u6570\u636e\uff1a" + AESUtils.showByteArray(encryptData));
        final String hexStr = Hex.encodeHexStr(encryptData);
        EadTest.log.info("\u52a0\u5bc6\u540e\u6570\u636e: hexStr:" + hexStr);
        final byte[] b = AESUtils.decrypt(Hex.decodeHex(hexStr.toCharArray()), key);
        EadTest.log.info("\u89e3\u5bc6\u6570\u636e\u6570\u636e: string:" + new String(b));
        final String a = AESUtils.encodeHex(data, k);
        EadTest.log.info("encodeHex \u52a0\u5bc6\u6570\u636e\u6570\u636e: string:" + a);
        final String a2 = AESUtils.decodeHex(a, k);
        EadTest.log.info("encodeHex \u89e3\u5bc6\u6570\u636e\u6570\u636e: string:" + a2);
        final String strs = "\u94f6\u884c\u5361\u662f\u7684\u6cd5\u5e08\u6253\u53d1\u7b97\u6cd5\u963f\u65af\u8482\u82ac";
        final String key2 = "1234abcd";
        final String enStr = DESUtils.encrypt(strs, key2);
        EadTest.log.info("\u539f\u65871:" + strs);
        EadTest.log.info("\u5bc6\u65871:" + enStr + "  " + enStr.length());
        final String str = DESUtils.decrypt(enStr, key2);
        System.out.println("\u89e3\u5bc61:" + str);
    }
    
    static {
        log = LoggerFactory.getLogger((Class)EadTest.class);
    }
}
